package org.nterlearning.datamodel.catalog.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.DateUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import org.nterlearning.datamodel.catalog.model.CourseReview;
import org.nterlearning.datamodel.catalog.model.CourseReviewModel;

import java.io.Serializable;

import java.sql.Types;

import java.util.Date;

/**
 * The base model implementation for the CourseReview service. Represents a row in the &quot;CATALOG_CourseReview&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link org.nterlearning.datamodel.catalog.model.CourseReviewModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CourseReviewImpl}.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see CourseReviewImpl
 * @see org.nterlearning.datamodel.catalog.model.CourseReview
 * @see org.nterlearning.datamodel.catalog.model.CourseReviewModel
 * @generated
 */
public class CourseReviewModelImpl extends BaseModelImpl<CourseReview>
    implements CourseReviewModel {
    /*
     * NOTE FOR DEVELOPERS:
     *
     * Never modify or reference this class directly. All methods that expect a course review model instance should use the {@link org.nterlearning.datamodel.catalog.model.CourseReview} interface instead.
     */
    public static final String TABLE_NAME = "CATALOG_CourseReview";
    public static final Object[][] TABLE_COLUMNS = {
            { "courseReviewId", Types.BIGINT },
            { "companyId", Types.BIGINT },
            { "groupId", Types.BIGINT },
            { "courseId", Types.BIGINT },
            { "userId", Types.BIGINT },
            { "summary", Types.VARCHAR },
            { "content", Types.VARCHAR },
            { "createDate", Types.TIMESTAMP },
            { "modifiedDate", Types.TIMESTAMP },
            { "weightedScore", Types.DOUBLE },
            { "removed", Types.BOOLEAN },
            { "removedDate", Types.TIMESTAMP }
        };
    public static final String TABLE_SQL_CREATE = "create table CATALOG_CourseReview (courseReviewId LONG not null primary key,companyId LONG,groupId LONG,courseId LONG,userId LONG,summary VARCHAR(250) null,content VARCHAR(3999) null,createDate DATE null,modifiedDate DATE null,weightedScore DOUBLE,removed BOOLEAN,removedDate DATE null)";
    public static final String TABLE_SQL_DROP = "drop table CATALOG_CourseReview";
    public static final String ORDER_BY_JPQL = " ORDER BY courseReview.weightedScore DESC, courseReview.modifiedDate DESC";
    public static final String ORDER_BY_SQL = " ORDER BY CATALOG_CourseReview.weightedScore DESC, CATALOG_CourseReview.modifiedDate DESC";
    public static final String DATA_SOURCE = "liferayDataSource";
    public static final String SESSION_FACTORY = "liferaySessionFactory";
    public static final String TX_MANAGER = "liferayTransactionManager";
    public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.entity.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseReview"),
            true);
    public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.finder.cache.enabled.org.nterlearning.datamodel.catalog.model.CourseReview"),
            true);
    public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
                "value.object.column.bitmask.enabled.org.nterlearning.datamodel.catalog.model.CourseReview"),
            true);
    public static long COMPANYID_COLUMN_BITMASK = 1L;
    public static long COURSEID_COLUMN_BITMASK = 2L;
    public static long GROUPID_COLUMN_BITMASK = 4L;
    public static long REMOVED_COLUMN_BITMASK = 8L;
    public static long USERID_COLUMN_BITMASK = 16L;
    public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
                "lock.expiration.time.org.nterlearning.datamodel.catalog.model.CourseReview"));
    private static ClassLoader _classLoader = CourseReview.class.getClassLoader();
    private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
            CourseReview.class
        };
    private long _courseReviewId;
    private long _companyId;
    private long _originalCompanyId;
    private boolean _setOriginalCompanyId;
    private long _groupId;
    private long _originalGroupId;
    private boolean _setOriginalGroupId;
    private long _courseId;
    private long _originalCourseId;
    private boolean _setOriginalCourseId;
    private long _userId;
    private String _userUuid;
    private long _originalUserId;
    private boolean _setOriginalUserId;
    private String _summary;
    private String _content;
    private Date _createDate;
    private Date _modifiedDate;
    private double _weightedScore;
    private boolean _removed;
    private boolean _originalRemoved;
    private boolean _setOriginalRemoved;
    private Date _removedDate;
    private transient ExpandoBridge _expandoBridge;
    private long _columnBitmask;
    private CourseReview _escapedModelProxy;

    public CourseReviewModelImpl() {
    }

    public long getPrimaryKey() {
        return _courseReviewId;
    }

    public void setPrimaryKey(long primaryKey) {
        setCourseReviewId(primaryKey);
    }

    public Serializable getPrimaryKeyObj() {
        return new Long(_courseReviewId);
    }

    public void setPrimaryKeyObj(Serializable primaryKeyObj) {
        setPrimaryKey(((Long) primaryKeyObj).longValue());
    }

    public Class<?> getModelClass() {
        return CourseReview.class;
    }

    public String getModelClassName() {
        return CourseReview.class.getName();
    }

    public long getCourseReviewId() {
        return _courseReviewId;
    }

    public void setCourseReviewId(long courseReviewId) {
        _courseReviewId = courseReviewId;
    }

    public long getCompanyId() {
        return _companyId;
    }

    public void setCompanyId(long companyId) {
        _columnBitmask |= COMPANYID_COLUMN_BITMASK;

        if (!_setOriginalCompanyId) {
            _setOriginalCompanyId = true;

            _originalCompanyId = _companyId;
        }

        _companyId = companyId;
    }

    public long getOriginalCompanyId() {
        return _originalCompanyId;
    }

    public long getGroupId() {
        return _groupId;
    }

    public void setGroupId(long groupId) {
        _columnBitmask |= GROUPID_COLUMN_BITMASK;

        if (!_setOriginalGroupId) {
            _setOriginalGroupId = true;

            _originalGroupId = _groupId;
        }

        _groupId = groupId;
    }

    public long getOriginalGroupId() {
        return _originalGroupId;
    }

    public long getCourseId() {
        return _courseId;
    }

    public void setCourseId(long courseId) {
        _columnBitmask |= COURSEID_COLUMN_BITMASK;

        if (!_setOriginalCourseId) {
            _setOriginalCourseId = true;

            _originalCourseId = _courseId;
        }

        _courseId = courseId;
    }

    public long getOriginalCourseId() {
        return _originalCourseId;
    }

    public long getUserId() {
        return _userId;
    }

    public void setUserId(long userId) {
        _columnBitmask |= USERID_COLUMN_BITMASK;

        if (!_setOriginalUserId) {
            _setOriginalUserId = true;

            _originalUserId = _userId;
        }

        _userId = userId;
    }

    public String getUserUuid() throws SystemException {
        return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
    }

    public void setUserUuid(String userUuid) {
        _userUuid = userUuid;
    }

    public long getOriginalUserId() {
        return _originalUserId;
    }

    public String getSummary() {
        if (_summary == null) {
            return StringPool.BLANK;
        } else {
            return _summary;
        }
    }

    public void setSummary(String summary) {
        _summary = summary;
    }

    public String getContent() {
        if (_content == null) {
            return StringPool.BLANK;
        } else {
            return _content;
        }
    }

    public void setContent(String content) {
        _content = content;
    }

    public Date getCreateDate() {
        return _createDate;
    }

    public void setCreateDate(Date createDate) {
        _createDate = createDate;
    }

    public Date getModifiedDate() {
        return _modifiedDate;
    }

    public void setModifiedDate(Date modifiedDate) {
        _columnBitmask = -1L;

        _modifiedDate = modifiedDate;
    }

    public double getWeightedScore() {
        return _weightedScore;
    }

    public void setWeightedScore(double weightedScore) {
        _columnBitmask = -1L;

        _weightedScore = weightedScore;
    }

    public boolean getRemoved() {
        return _removed;
    }

    public boolean isRemoved() {
        return _removed;
    }

    public void setRemoved(boolean removed) {
        _columnBitmask |= REMOVED_COLUMN_BITMASK;

        if (!_setOriginalRemoved) {
            _setOriginalRemoved = true;

            _originalRemoved = _removed;
        }

        _removed = removed;
    }

    public boolean getOriginalRemoved() {
        return _originalRemoved;
    }

    public Date getRemovedDate() {
        return _removedDate;
    }

    public void setRemovedDate(Date removedDate) {
        _removedDate = removedDate;
    }

    public long getColumnBitmask() {
        return _columnBitmask;
    }

    @Override
    public CourseReview toEscapedModel() {
        if (_escapedModelProxy == null) {
            _escapedModelProxy = (CourseReview) ProxyUtil.newProxyInstance(_classLoader,
                    _escapedModelProxyInterfaces,
                    new AutoEscapeBeanHandler(this));
        }

        return _escapedModelProxy;
    }

    @Override
    public ExpandoBridge getExpandoBridge() {
        if (_expandoBridge == null) {
            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
                    CourseReview.class.getName(), getPrimaryKey());
        }

        return _expandoBridge;
    }

    @Override
    public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
        getExpandoBridge().setAttributes(serviceContext);
    }

    @Override
    public Object clone() {
        CourseReviewImpl courseReviewImpl = new CourseReviewImpl();

        courseReviewImpl.setCourseReviewId(getCourseReviewId());
        courseReviewImpl.setCompanyId(getCompanyId());
        courseReviewImpl.setGroupId(getGroupId());
        courseReviewImpl.setCourseId(getCourseId());
        courseReviewImpl.setUserId(getUserId());
        courseReviewImpl.setSummary(getSummary());
        courseReviewImpl.setContent(getContent());
        courseReviewImpl.setCreateDate(getCreateDate());
        courseReviewImpl.setModifiedDate(getModifiedDate());
        courseReviewImpl.setWeightedScore(getWeightedScore());
        courseReviewImpl.setRemoved(getRemoved());
        courseReviewImpl.setRemovedDate(getRemovedDate());

        courseReviewImpl.resetOriginalValues();

        return courseReviewImpl;
    }

    public int compareTo(CourseReview courseReview) {
        int value = 0;

        if (getWeightedScore() < courseReview.getWeightedScore()) {
            value = -1;
        } else if (getWeightedScore() > courseReview.getWeightedScore()) {
            value = 1;
        } else {
            value = 0;
        }

        value = value * -1;

        if (value != 0) {
            return value;
        }

        value = DateUtil.compareTo(getModifiedDate(),
                courseReview.getModifiedDate());

        value = value * -1;

        if (value != 0) {
            return value;
        }

        return 0;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }

        CourseReview courseReview = null;

        try {
            courseReview = (CourseReview) obj;
        } catch (ClassCastException cce) {
            return false;
        }

        long primaryKey = courseReview.getPrimaryKey();

        if (getPrimaryKey() == primaryKey) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (int) getPrimaryKey();
    }

    @Override
    public void resetOriginalValues() {
        CourseReviewModelImpl courseReviewModelImpl = this;

        courseReviewModelImpl._originalCompanyId = courseReviewModelImpl._companyId;

        courseReviewModelImpl._setOriginalCompanyId = false;

        courseReviewModelImpl._originalGroupId = courseReviewModelImpl._groupId;

        courseReviewModelImpl._setOriginalGroupId = false;

        courseReviewModelImpl._originalCourseId = courseReviewModelImpl._courseId;

        courseReviewModelImpl._setOriginalCourseId = false;

        courseReviewModelImpl._originalUserId = courseReviewModelImpl._userId;

        courseReviewModelImpl._setOriginalUserId = false;

        courseReviewModelImpl._originalRemoved = courseReviewModelImpl._removed;

        courseReviewModelImpl._setOriginalRemoved = false;

        courseReviewModelImpl._columnBitmask = 0;
    }

    @Override
    public CacheModel<CourseReview> toCacheModel() {
        CourseReviewCacheModel courseReviewCacheModel = new CourseReviewCacheModel();

        courseReviewCacheModel.courseReviewId = getCourseReviewId();

        courseReviewCacheModel.companyId = getCompanyId();

        courseReviewCacheModel.groupId = getGroupId();

        courseReviewCacheModel.courseId = getCourseId();

        courseReviewCacheModel.userId = getUserId();

        courseReviewCacheModel.summary = getSummary();

        String summary = courseReviewCacheModel.summary;

        if ((summary != null) && (summary.length() == 0)) {
            courseReviewCacheModel.summary = null;
        }

        courseReviewCacheModel.content = getContent();

        String content = courseReviewCacheModel.content;

        if ((content != null) && (content.length() == 0)) {
            courseReviewCacheModel.content = null;
        }

        Date createDate = getCreateDate();

        if (createDate != null) {
            courseReviewCacheModel.createDate = createDate.getTime();
        } else {
            courseReviewCacheModel.createDate = Long.MIN_VALUE;
        }

        Date modifiedDate = getModifiedDate();

        if (modifiedDate != null) {
            courseReviewCacheModel.modifiedDate = modifiedDate.getTime();
        } else {
            courseReviewCacheModel.modifiedDate = Long.MIN_VALUE;
        }

        courseReviewCacheModel.weightedScore = getWeightedScore();

        courseReviewCacheModel.removed = getRemoved();

        Date removedDate = getRemovedDate();

        if (removedDate != null) {
            courseReviewCacheModel.removedDate = removedDate.getTime();
        } else {
            courseReviewCacheModel.removedDate = Long.MIN_VALUE;
        }

        return courseReviewCacheModel;
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(25);

        sb.append("{courseReviewId=");
        sb.append(getCourseReviewId());
        sb.append(", companyId=");
        sb.append(getCompanyId());
        sb.append(", groupId=");
        sb.append(getGroupId());
        sb.append(", courseId=");
        sb.append(getCourseId());
        sb.append(", userId=");
        sb.append(getUserId());
        sb.append(", summary=");
        sb.append(getSummary());
        sb.append(", content=");
        sb.append(getContent());
        sb.append(", createDate=");
        sb.append(getCreateDate());
        sb.append(", modifiedDate=");
        sb.append(getModifiedDate());
        sb.append(", weightedScore=");
        sb.append(getWeightedScore());
        sb.append(", removed=");
        sb.append(getRemoved());
        sb.append(", removedDate=");
        sb.append(getRemovedDate());
        sb.append("}");

        return sb.toString();
    }

    public String toXmlString() {
        StringBundler sb = new StringBundler(40);

        sb.append("<model><model-name>");
        sb.append("org.nterlearning.datamodel.catalog.model.CourseReview");
        sb.append("</model-name>");

        sb.append(
            "<column><column-name>courseReviewId</column-name><column-value><![CDATA[");
        sb.append(getCourseReviewId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>companyId</column-name><column-value><![CDATA[");
        sb.append(getCompanyId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>groupId</column-name><column-value><![CDATA[");
        sb.append(getGroupId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>courseId</column-name><column-value><![CDATA[");
        sb.append(getCourseId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>userId</column-name><column-value><![CDATA[");
        sb.append(getUserId());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>summary</column-name><column-value><![CDATA[");
        sb.append(getSummary());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>content</column-name><column-value><![CDATA[");
        sb.append(getContent());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>createDate</column-name><column-value><![CDATA[");
        sb.append(getCreateDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
        sb.append(getModifiedDate());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>weightedScore</column-name><column-value><![CDATA[");
        sb.append(getWeightedScore());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>removed</column-name><column-value><![CDATA[");
        sb.append(getRemoved());
        sb.append("]]></column-value></column>");
        sb.append(
            "<column><column-name>removedDate</column-name><column-value><![CDATA[");
        sb.append(getRemovedDate());
        sb.append("]]></column-value></column>");

        sb.append("</model>");

        return sb.toString();
    }
}
